package com.zhny.aiot.solar.roll.film.plugin;

import com.zhny.aiot.plugin.ICenterFacilities;
import com.zhny.aiot.plugin.IDevice;
import com.zhny.aiot.plugin.model.CommandEntry;
import com.zhny.aiot.plugin.model.DeviceEntity;
import com.zhny.aiot.plugin.model.FactoryType;
import com.zhny.aiot.plugin.model.StoreEntity;
import com.zhny.aiot.plugin.zhnygateway.GatewayServer;
import com.zhny.aiot.plugin.zhnygateway.device.ZhnyDeviceFactory;
import com.zhny.aiot.solar.roll.film.plugin.model.RollFilmStoreEntry;
import org.pf4j.Extension;
import org.pf4j.Plugin;
import org.pf4j.PluginWrapper;

import java.util.List;

public class SolarRollFilmPlugin extends Plugin {
    public SolarRollFilmPlugin(PluginWrapper wrapper) {
        super(wrapper);
    }

    @Extension
    public static class SolarRollFilmFactory extends ZhnyDeviceFactory<RollFilmStoreEntry>{

        @Override
        public List<CommandEntry> supportCommandClasses() {
            List<CommandEntry> commands = super.supportCommandClasses ();
            commands.add(CommandEntry.valueOf("open", "打开","无参数",null));
            commands.add(CommandEntry.valueOf("close", "关闭","无参数", null));
            commands.add(CommandEntry.valueOf("stop", "停止","无参数", null));
            commands.add(CommandEntry.valueOf("query", "检测","无参数", null));
            commands.add(CommandEntry.valueOf("queryVoltage", "查询阀门电压", "无参数",null));
            return commands;
        }

        public IDevice createDevice(ICenterFacilities iCenterFacilities, DeviceEntity entity) {
            return new SolarRollFilmDevice (GatewayServer.getInstance ().getEngine () ,this,iCenterFacilities,entity);
        }

        public Class<? extends StoreEntity> storeClass() {
            return RollFilmStoreEntry.class;
        }

        public String getId() {
            return "zhny-solar-roll-film-plugin";
        }

        public String getName() {
            return "智慧太阳能卷膜器插件";
        }

        public FactoryType getType() {
            return FactoryType.RollFilm;
        }
    }
}
